package com.diy.sigmund.diycommon.designpatterns.command;

/**
 * 使用状态实现撤销
 * <br>吊扇源码如下
 *
 * @author ylm-sigmund
 * @since 2022/2/9 14:16
 */
public class CeilingFan {

    String location;
    int speed;
    public static final int OFF = 0;
    public static final int LOW = 1;
    public static final int MEDIUM = 2;
    public static final int HIGH = 3;

    public CeilingFan(String location) {
        this.location = location;
        this.speed = OFF;
    }

    public void off() {
        speed = OFF;
        System.out.println(location + " CeilingFan OFF");
    }

    public void low() {
        speed = LOW;
        System.out.println(location + " CeilingFan LOW");
    }

    public void medium() {
        speed = MEDIUM;
        System.out.println(location + " CeilingFan MEDIUM");
    }

    public void high() {
        speed = HIGH;
        System.out.println(location + " CeilingFan HIGH");
    }

    public int getSpeed() {
        return speed;
    }
}
